package json;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;

import java.util.HashMap;
import java.util.Map;

public class JackJsonDemo {

  public static void main(String[] args) {

    ObjectMapper objectMapper = new ObjectMapper();
    objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
    Map<String, Object> map = new HashMap<>();
    map.put("i", 1);
    map.put("do", null);

    String s = null;
    try {
      s = objectMapper.writeValueAsString(map);
    } catch (JsonProcessingException e) {
      e.printStackTrace();
    }
    System.out.println(s);

  }

}
